#ifndef FILEWRITER_H
#define FILEWRITER_H
#include <QFile>

#include "metainfo.h"

class QDir;

class FileWriter : public QObject
{
    Q_OBJECT
public:
    FileWriter(const MetaInfo& fileInfo, const QDir& dir, QObject* parent);
    ~FileWriter();
    void createAndOpenFile();
    void writeToFile(int offset, const QByteArray& data);
    const QByteArray& readFromFile(int offset, quint32 size);
    void setFileDownloaded(bool downloaded);
    void closeFile();
signals:
   void error(const QString& reason);
private:
    QFile* file;
    MetaInfo fileMetaInfo;
    QByteArray* readBuffer;
    bool isDownloaded;
};

#endif // FILEWRITER_H
